﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Xml;
using BoYuan.DBServices;
using BoYuan.FineUIMvcWeb.Code;

using BoYuan.Framework.Uitility;
using FineUIMvc;

namespace BoYuan.MvcCodeGenerator.Controllers
{
   
    public class HomeController : BaseController
    {
        // GET: Home
        public ActionResult Index()
        {
            LoadData();

            return View("Index");
        }

        // GET: Themes
        public ActionResult Themes()
        {
            return View();
        }
        
        #region LoadData

        private string _cookieMenuStyle = "tree";
        private bool _cookieShowOnlyBase = false;
        private string _cookieDisplayMode = "normal";
        private string _cookieMainTabs = "multi";
        private string _cookieLang = "zh_CN";
      

        private void LoadData()
        {
            HttpCookie cookie = null;

            // 从Cookie中读取 - 是否仅显示基础版示例
            cookie = Request.Cookies["ShowOnlyBase"];
            if (cookie != null)
            {
                _cookieShowOnlyBase = Convert.ToBoolean(cookie.Value);
            }


            // 如果是FineUIMvc（基础版），或者用户选择仅显示基础版示例
            if (_cookieShowOnlyBase || Constants.IS_BASE)
            {
                // 基础版不支持紧凑模式，大字体模式，大间距模式，智能树菜单
                _cookieMenuStyle = "plaintree";
                _cookieDisplayMode = "normal";
            }
            else
            {
                // 从Cookie中读取 - 左侧菜单类型
                cookie = Request.Cookies["MenuStyle"];
                if (cookie != null)
                {
                    _cookieMenuStyle = cookie.Value;
                }

                // 从Cookie中读取 - 显示模式
                cookie = Request.Cookies["DisplayMode"];
                if (cookie != null)
                {
                    _cookieDisplayMode = cookie.Value;
                }
            }


            // 从Cookie中读取 - 语言
            cookie = Request.Cookies["Language"];
            if (cookie != null)
            {
                _cookieLang = cookie.Value;
            }

            // 从Cookie中读取 - 主选项卡标签
            cookie = Request.Cookies["MainTabs"];
            if (cookie != null)
            {
                _cookieMainTabs = cookie.Value;
            }

            ViewBag.CookieMenuStyle = _cookieMenuStyle;
            ViewBag.CookieShowOnlyBase = _cookieShowOnlyBase;
            ViewBag.CookieIsBase = Constants.IS_BASE;
            ViewBag.CookieDisplayMode = _cookieDisplayMode;
            ViewBag.CookieMainTabs = _cookieMainTabs;
            ViewBag.CookieLang = _cookieLang;

            ViewBag.ProductVersion = GlobalConfig.ProductVersion;
        }

        #endregion

    }
}